﻿// News Framework
// (C) Tanzim Saqib. Oct 25, 2010.
// http://TanzimSaqib.com | http://newsfx.codeplex.com

namespace TanzimSaqib.NewsFramework.Demo
{
    using System.Windows;

    public partial class App : Application
    {
        public App()
        {
            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = false;

                // Show the areas of the app that are being redrawn in each frame.
                Application.Current.Host.Settings.EnableRedrawRegions = false;

                // Enable non-production analysis visualization mode, 
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                Application.Current.Host.Settings.EnableCacheVisualization = false;
            }

            // Standard Silverlight initialization
            InitializeComponent();

            // Initialize NewsFramework
            Fx.Initialize(this, new RssExtendedParser()
                                    {
                                        ThumbnailParser = (item) =>
                                        {
                                            Check.Null(item);

                                            return item.Element(item.GetNamespaceOfPrefix("mash") + "thumbnail")
                                                .Element("img")
                                                .Attribute("src")
                                                .Value;
                                        },

                                        ContentParser = (item) =>
                                        {
                                            Check.Null(item);

                                            return item.Element(item.GetNamespaceOfPrefix("content") + "encoded")
                                                    .Value;
                                        }
                                    });
        }
    }
}